#ifndef YMODEMWINDOW_H
#define YMODEMWINDOW_H

#include <QMainWindow>
#include "YmodemFileTransmit.h"
#include "YmodemFileReceive.h"

namespace Ui {
class YmodemWindow;
}

class YmodemWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit YmodemWindow(QWidget *parent = nullptr);
    ~YmodemWindow();

private:
    void loadConfig();
    void loadDefaultConfig();
    bool readConfig();
    void saveConfig();

protected:
    void closeEvent(QCloseEvent *env);

private slots:
    void on_openBtn_clicked();
    void on_transmitBrowse_clicked();
    void on_receiveBrowse_clicked();
    void on_transmitBtn_clicked();
    void on_receiveBtn_clicked();
    void transmitProgress(int progress);
    void receiveProgress(int progress);
    void transmitStatus(YmodemFileTransmit::Status status);
    void receiveStatus(YmodemFileReceive::Status status);

private:
    Ui::YmodemWindow *ui;
    QSerialPort *serialPort;
    YmodemFileTransmit *ymodemFileTransmit;
    YmodemFileReceive *ymodemFileReceive;

    bool inTransmitting;
    bool inReceiving;
};

#endif // YMODEMWINDOW_H
